#!/bin/bash
echo "COMPILO IL BOOT"
nasm -fbin boot/boot.asm -o object/boot.bin
echo "COMPILO IL MAIN"
gcc  -fomit-frame-pointer -O -nostdlib  -march=i386 -nostdinc -I./include -c -o object/main.o main.c
echo "COMPILO IL GESTORE DEGLI INTERRUPT"
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/pic8259.o interrupt/pic8259.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/idt.o interrupt/idt.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/irq.o interrupt/irq.c
echo "COMPILO LE FUNZIONI DEL KERNEL"
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/io_port.o kernel/io_port.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/video.o kernel/video.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/keyboard.o kernel/keyboard.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/string.o kernel/string.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/cmos.o kernel/cmos.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/cpu_t.o kernel/cpu.c
#gcc	-o object/cpu_funct.o kernel/cpu.s
#gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/cpu_t.o kernel/cpu.c
echo "COMPILO I DRIVER"
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/video_driver.o driver/video.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/keyboard_driver.o driver/keyboard.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/timer.o driver/timer.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/serial.o driver/serial.c
echo "COMPILO LA GESTIONE DELLA MEMORIA"
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/ram.o mem/ram.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/mem_fisica.o mem/mem_fisica.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/mem_virtuale.o mem/mem_virtuale.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/malloc.o mem/malloc.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/gdt.o mem/gdt.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/paging.o mem/paging.c
#echo "COMPILO IL TASK"
#gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -c -o object/scheduler.o task/scheduler.c
echo "COMPILO LE APPLICAZIONI"
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -fno-stack-protector -c -o object/console.o app/console.c
gcc  -fomit-frame-pointer -O  -nostdlib  -march=i386 -nostdinc -I./include -fno-stack-protector -c -o object/mapper.o app/mapper.c
echo "UNISCO IL TUTTO"
ld  -Bstatic --oformat binary -o object/kernel.bin object/main.o object/video_driver.o object/keyboard_driver.o object/io_port.o object/pic8259.o object/idt.o object/video.o object/irq.o object/keyboard.o object/string.o object/console.o object/timer.o object/cmos.o object/ram.o object/malloc.o object/mem_fisica.o object/mem_virtuale.o object/gdt.o object/paging.o object/cpu_t.o object/serial.o object/mapper.o -Ttext 0x10000 -Map kernel.map
cat object/boot.bin object/kernel.bin > os.img

echo " "
echo "SCRITTURA IMMAGINE SU FLOPPY..."
echo " "

dd if=os.img of=/dev/fd0

echo " "
echo "FATTO!"
